home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 …ember: Reference Library / Apple Developer Reference Library (December 1999) (Disk 1).iso / pc / technical documentation / develop / develop issue 26 / develop issue 26 code / truffles - display mgr. / superfly source / superflyappleeventhandler.cp < prev    next >
Encoding:
Text File  |  1996-02-07  |  2.7 KB  |  97 lines

  1. /*
  2.     File:        SuperFlyAppleEventHandler.cp
  3.  
  4.     Contains:    Routines to install and handle the Display Manager's Apple Event
  5.                 
  6.     Written by: Kent Miller
  7.     
  8.     Copyright:    © 1996 Apple Computer
  9.  
  10.     Change History (most recent first):
  11.  
  12.  */
  13.  
  14. //From the Sprocket Lib
  15. #include "AppleEventHandling.h"
  16.  
  17. //SuperFly includes
  18. #include "GDeviceUtilities.h"
  19. #include "SuperFlyAppleEventHandler.h"
  20. #include "SuperFly.h"
  21.  
  22. OSErr
  23. InstallDisplayManagerEventHandler(void)
  24.     {
  25.     return AEInstallEventHandler(kCoreEventClass,kAESystemConfigNotice,NewAEEventHandlerProc(HandleDisplayManagerEvent),0,false);
  26.     }
  27.  
  28.  
  29. pascal OSErr
  30. HandleDisplayManagerEvent(AppleEvent *theAppleEvent,AppleEvent * /* reply */,long /* refCon */)
  31.     {
  32.     AEDescList    DisplayList, DisplayID;
  33.     long        displayCount;
  34.     AERecord    OldConfig, NewConfig;
  35.     AEKeyword    tempWord;
  36.     AEDesc        returnType;
  37.     OSErr        myErr;
  38.     Rect        oldRect, newRect;
  39.     SInt16        oldDepth, newDepth;
  40.     Boolean        graphicsWorldChanged = false;
  41.         
  42.     if ((myErr = AEGetParamDesc(theAppleEvent,kAEDisplayNotice, typeWildCard, &DisplayList)) != noErr)
  43.         return myErr;
  44.     
  45.     if ((myErr = CheckAppleEventForMissingParams(theAppleEvent)) != noErr)
  46.         return myErr;
  47.     
  48.     if ((myErr = AECountItems(&DisplayList,&displayCount)) != noErr)
  49.         return myErr;
  50.  
  51.     if ( CountUniqueDeviceRects() != gMyWindowList->CountListItems())
  52.         graphicsWorldChanged = true;
  53.     else
  54.         {
  55.         while (displayCount > 0)
  56.             {
  57.             //From Display Manager developer note, September 1995 developer CD
  58.         
  59.             AEGetNthDesc(&DisplayList, displayCount, typeWildCard, &tempWord, &DisplayID);
  60.             AEGetNthDesc(&DisplayID, 1, typeWildCard, &tempWord, &OldConfig);
  61.             AEGetNthDesc(&DisplayID, 2, typeWildCard, &tempWord, &NewConfig);
  62.     
  63.             //Did the bitdepth change?
  64.             AEGetKeyPtr(&OldConfig, keyPixMapCmpSize, typeWildCard, (UInt32 *) &returnType, &oldDepth, 2, nil);
  65.             AEGetKeyPtr(&NewConfig, keyPixMapCmpSize, typeWildCard, (UInt32 *) &returnType, &newDepth, 2, nil);        
  66.             if (oldDepth != newDepth)
  67.                 {
  68.                 //maybe do something here if you're interested in bit depth changes
  69.                 }
  70.                 
  71.             //Did the devices move or something like that?
  72.             AEGetKeyPtr(&OldConfig, keyDeviceRect, typeWildCard, (UInt32 *) &returnType, &oldRect, sizeof(Rect), nil);
  73.             AEGetKeyPtr(&NewConfig, keyDeviceRect, typeWildCard, (UInt32 *) &returnType, &newRect, sizeof(Rect), nil);        
  74.             if (! EqualRect(&oldRect, &newRect) )
  75.                 {
  76.                 SuperFlyHandleGDevicesMoved();
  77.                 }
  78.             displayCount--;
  79.  
  80.             (void) AEDisposeDesc(&DisplayID);
  81.             (void) AEDisposeDesc(&OldConfig);
  82.             (void) AEDisposeDesc(&NewConfig);
  83.             }
  84.         }
  85.  
  86.     (void) AEDisposeDesc(&DisplayList);
  87.  
  88.     if (graphicsWorldChanged)
  89.         {
  90.         SuperFlySetUpWindows();
  91.         if (gMyToolWindow)
  92.             gMyToolWindow->MoveToRelativePosition();
  93.         }
  94.  
  95.     return noErr;    //    we really don’t handle this yet...
  96.     }
  97.